package com.auth.common.exception;

import com.common.global.GlobalBaseEnum;
import org.springframework.http.HttpStatus;

/**
 * Error code
 *
 * @description: 规范错误码
 * @author: cyj
 * @date 2020 -10-15 16:59:31
 */
public enum ErrorCode implements GlobalBaseEnum {

    /**
     * Unknow error error code
     */
    UNKNOW_ERROR("1.1.0001", "未知异常", HttpStatus.INTERNAL_SERVER_ERROR),
    /**
     * In params error error code
     */
    IN_PARAMS_ERROR("1.1.0002", "入参校验异常[%s]", HttpStatus.BAD_REQUEST),
    /**
     * Validator error error code
     */
    VALIDATOR_ERROR("1.1.0003", "参数校验异常[%s]", HttpStatus.INTERNAL_SERVER_ERROR),
    /**
     * Token expire error code
     */
    TOKEN_EXPIRE("1.1.0004", "凭证已过期,请重新登陆", HttpStatus.UNAUTHORIZED),
    /**
     * Token create error error code
     */
    TOKEN_CREATE_ERROR("1.1.0005", "凭证创建失败", HttpStatus.UNAUTHORIZED),
    /**
     * User not found 2 error code
     */
    USER_NOT_FOUND2("1.1.0006", "用户不存在", HttpStatus.UNAUTHORIZED),
    /**
     * Password error error code
     */
    PASSWORD_ERROR("1.1.0007", "密码错误登陆失败", HttpStatus.UNAUTHORIZED),
    /**
     * Illegal access error code
     */
    ILLEGAL_ACCESS("1.1.0008", "非法访问", HttpStatus.UNAUTHORIZED),
    /**
     * Permission denied error code
     */
    PERMISSION_DENIED("1.1.0009", "权限不足", HttpStatus.UNAUTHORIZED),
    /**
     * Permission denied role error code
     */
    PERMISSION_DENIED_ROLE("1.1.0010", "权限不足, 需要[%s]角色", HttpStatus.UNAUTHORIZED),
    /**
     * Permission denied auth error code
     */
    PERMISSION_DENIED_AUTH("1.1.0011", "权限不足, 需要[%s]权限", HttpStatus.UNAUTHORIZED),

    /**
     * User not found error code
     */
    USER_NOT_FOUND("1.1.1001", "查询不到该用户", HttpStatus.OK);

    /**
     * Code
     */
    public String code;

    /**
     * Message
     */
    public String message;

    /**
     * Http status
     */
    public HttpStatus httpStatus;

    /**
     * Error code
     *
     * @param code       code
     * @param message    message
     * @param httpStatus http status
     */
    ErrorCode(String code, String message, HttpStatus httpStatus) {
        this.code = code;
        this.message = message;
        this.httpStatus = httpStatus;
    }


    @Override
    public String code() {
        return this.code;
    }

    @Override
    public String message() {
        return this.message;
    }
}
